{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Channel</th>\n",
       "      <th>Region</th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>12669</td>\n",
       "      <td>9656</td>\n",
       "      <td>7561</td>\n",
       "      <td>214</td>\n",
       "      <td>2674</td>\n",
       "      <td>1338</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>7057</td>\n",
       "      <td>9810</td>\n",
       "      <td>9568</td>\n",
       "      <td>1762</td>\n",
       "      <td>3293</td>\n",
       "      <td>1776</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>6353</td>\n",
       "      <td>8808</td>\n",
       "      <td>7684</td>\n",
       "      <td>2405</td>\n",
       "      <td>3516</td>\n",
       "      <td>7844</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>13265</td>\n",
       "      <td>1196</td>\n",
       "      <td>4221</td>\n",
       "      <td>6404</td>\n",
       "      <td>507</td>\n",
       "      <td>1788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>22615</td>\n",
       "      <td>5410</td>\n",
       "      <td>7198</td>\n",
       "      <td>3915</td>\n",
       "      <td>1777</td>\n",
       "      <td>5185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>435</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>29703</td>\n",
       "      <td>12051</td>\n",
       "      <td>16027</td>\n",
       "      <td>13135</td>\n",
       "      <td>182</td>\n",
       "      <td>2204</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>39228</td>\n",
       "      <td>1431</td>\n",
       "      <td>764</td>\n",
       "      <td>4510</td>\n",
       "      <td>93</td>\n",
       "      <td>2346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>437</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>14531</td>\n",
       "      <td>15488</td>\n",
       "      <td>30243</td>\n",
       "      <td>437</td>\n",
       "      <td>14841</td>\n",
       "      <td>1867</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>438</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>10290</td>\n",
       "      <td>1981</td>\n",
       "      <td>2232</td>\n",
       "      <td>1038</td>\n",
       "      <td>168</td>\n",
       "      <td>2125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>439</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2787</td>\n",
       "      <td>1698</td>\n",
       "      <td>2510</td>\n",
       "      <td>65</td>\n",
       "      <td>477</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>440 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Channel  Region  Fresh   Milk  Grocery  Frozen  Detergents_Paper  \\\n",
       "0          2       3  12669   9656     7561     214              2674   \n",
       "1          2       3   7057   9810     9568    1762              3293   \n",
       "2          2       3   6353   8808     7684    2405              3516   \n",
       "3          1       3  13265   1196     4221    6404               507   \n",
       "4          2       3  22615   5410     7198    3915              1777   \n",
       "..       ...     ...    ...    ...      ...     ...               ...   \n",
       "435        1       3  29703  12051    16027   13135               182   \n",
       "436        1       3  39228   1431      764    4510                93   \n",
       "437        2       3  14531  15488    30243     437             14841   \n",
       "438        1       3  10290   1981     2232    1038               168   \n",
       "439        1       3   2787   1698     2510      65               477   \n",
       "\n",
       "     Delicassen  \n",
       "0          1338  \n",
       "1          1776  \n",
       "2          7844  \n",
       "3          1788  \n",
       "4          5185  \n",
       "..          ...  \n",
       "435        2204  \n",
       "436        2346  \n",
       "437        1867  \n",
       "438        2125  \n",
       "439          52  \n",
       "\n",
       "[440 rows x 8 columns]"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('Wholesale customers data.csv')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Channel</th>\n",
       "      <th>Region</th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1.322727</td>\n",
       "      <td>2.543182</td>\n",
       "      <td>12000.297727</td>\n",
       "      <td>5796.265909</td>\n",
       "      <td>7951.277273</td>\n",
       "      <td>3071.931818</td>\n",
       "      <td>2881.493182</td>\n",
       "      <td>1524.870455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.468052</td>\n",
       "      <td>0.774272</td>\n",
       "      <td>12647.328865</td>\n",
       "      <td>7380.377175</td>\n",
       "      <td>9503.162829</td>\n",
       "      <td>4854.673333</td>\n",
       "      <td>4767.854448</td>\n",
       "      <td>2820.105937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>55.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>25.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>112151.000000</td>\n",
       "      <td>73498.000000</td>\n",
       "      <td>92780.000000</td>\n",
       "      <td>60869.000000</td>\n",
       "      <td>40827.000000</td>\n",
       "      <td>47943.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Channel      Region          Fresh          Milk       Grocery  \\\n",
       "count  440.000000  440.000000     440.000000    440.000000    440.000000   \n",
       "mean     1.322727    2.543182   12000.297727   5796.265909   7951.277273   \n",
       "std      0.468052    0.774272   12647.328865   7380.377175   9503.162829   \n",
       "min      1.000000    1.000000       3.000000     55.000000      3.000000   \n",
       "max      2.000000    3.000000  112151.000000  73498.000000  92780.000000   \n",
       "\n",
       "             Frozen  Detergents_Paper    Delicassen  \n",
       "count    440.000000        440.000000    440.000000  \n",
       "mean    3071.931818       2881.493182   1524.870455  \n",
       "std     4854.673333       4767.854448   2820.105937  \n",
       "min       25.000000          3.000000      3.000000  \n",
       "max    60869.000000      40827.000000  47943.000000  "
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考过程，我也不删除了\n",
    "count=data.count()\n",
    "mean=data.mean()\n",
    "std=data.std()\n",
    "min=data.min()\n",
    "# data.sort_values()\n",
    "max=data.max()\n",
    "# b=pd.DataFrame({'count':a.values})\n",
    "new_data=pd.DataFrame({'count':count.values,'mean':mean.values,'std':std.values,'min':min.values,'max':max.values,},index=count.index)\n",
    "b=new_data.T\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Channel</th>\n",
       "      <th>Region</th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1.322727</td>\n",
       "      <td>2.543182</td>\n",
       "      <td>12000.297727</td>\n",
       "      <td>5796.265909</td>\n",
       "      <td>7951.277273</td>\n",
       "      <td>3071.931818</td>\n",
       "      <td>2881.493182</td>\n",
       "      <td>1524.870455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.468052</td>\n",
       "      <td>0.774272</td>\n",
       "      <td>12647.328865</td>\n",
       "      <td>7380.377175</td>\n",
       "      <td>9503.162829</td>\n",
       "      <td>4854.673333</td>\n",
       "      <td>4767.854448</td>\n",
       "      <td>2820.105937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>55.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>25.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3127.750000</td>\n",
       "      <td>1533.000000</td>\n",
       "      <td>2153.000000</td>\n",
       "      <td>742.250000</td>\n",
       "      <td>256.750000</td>\n",
       "      <td>408.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>8504.000000</td>\n",
       "      <td>3627.000000</td>\n",
       "      <td>4755.500000</td>\n",
       "      <td>1526.000000</td>\n",
       "      <td>816.500000</td>\n",
       "      <td>965.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>16933.750000</td>\n",
       "      <td>7190.250000</td>\n",
       "      <td>10655.750000</td>\n",
       "      <td>3554.250000</td>\n",
       "      <td>3922.000000</td>\n",
       "      <td>1820.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>112151.000000</td>\n",
       "      <td>73498.000000</td>\n",
       "      <td>92780.000000</td>\n",
       "      <td>60869.000000</td>\n",
       "      <td>40827.000000</td>\n",
       "      <td>47943.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Channel      Region          Fresh          Milk       Grocery  \\\n",
       "count  440.000000  440.000000     440.000000    440.000000    440.000000   \n",
       "mean     1.322727    2.543182   12000.297727   5796.265909   7951.277273   \n",
       "std      0.468052    0.774272   12647.328865   7380.377175   9503.162829   \n",
       "min      1.000000    1.000000       3.000000     55.000000      3.000000   \n",
       "25%      1.000000    2.000000    3127.750000   1533.000000   2153.000000   \n",
       "50%      1.000000    3.000000    8504.000000   3627.000000   4755.500000   \n",
       "75%      2.000000    3.000000   16933.750000   7190.250000  10655.750000   \n",
       "max      2.000000    3.000000  112151.000000  73498.000000  92780.000000   \n",
       "\n",
       "             Frozen  Detergents_Paper    Delicassen  \n",
       "count    440.000000        440.000000    440.000000  \n",
       "mean    3071.931818       2881.493182   1524.870455  \n",
       "std     4854.673333       4767.854448   2820.105937  \n",
       "min       25.000000          3.000000      3.000000  \n",
       "25%      742.250000        256.750000    408.250000  \n",
       "50%     1526.000000        816.500000    965.500000  \n",
       "75%     3554.250000       3922.000000   1820.250000  \n",
       "max    60869.000000      40827.000000  47943.000000  "
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t=data.describe()\n",
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>12000.297727</td>\n",
       "      <td>5796.265909</td>\n",
       "      <td>7951.277273</td>\n",
       "      <td>3071.931818</td>\n",
       "      <td>2881.493182</td>\n",
       "      <td>1524.870455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>12647.328865</td>\n",
       "      <td>7380.377175</td>\n",
       "      <td>9503.162829</td>\n",
       "      <td>4854.673333</td>\n",
       "      <td>4767.854448</td>\n",
       "      <td>2820.105937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>3.000000</td>\n",
       "      <td>55.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>25.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>3127.750000</td>\n",
       "      <td>1533.000000</td>\n",
       "      <td>2153.000000</td>\n",
       "      <td>742.250000</td>\n",
       "      <td>256.750000</td>\n",
       "      <td>408.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>8504.000000</td>\n",
       "      <td>3627.000000</td>\n",
       "      <td>4755.500000</td>\n",
       "      <td>1526.000000</td>\n",
       "      <td>816.500000</td>\n",
       "      <td>965.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>16933.750000</td>\n",
       "      <td>7190.250000</td>\n",
       "      <td>10655.750000</td>\n",
       "      <td>3554.250000</td>\n",
       "      <td>3922.000000</td>\n",
       "      <td>1820.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>112151.000000</td>\n",
       "      <td>73498.000000</td>\n",
       "      <td>92780.000000</td>\n",
       "      <td>60869.000000</td>\n",
       "      <td>40827.000000</td>\n",
       "      <td>47943.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Fresh          Milk       Grocery        Frozen  \\\n",
       "count     440.000000    440.000000    440.000000    440.000000   \n",
       "mean    12000.297727   5796.265909   7951.277273   3071.931818   \n",
       "std     12647.328865   7380.377175   9503.162829   4854.673333   \n",
       "min         3.000000     55.000000      3.000000     25.000000   \n",
       "25%      3127.750000   1533.000000   2153.000000    742.250000   \n",
       "50%      8504.000000   3627.000000   4755.500000   1526.000000   \n",
       "75%     16933.750000   7190.250000  10655.750000   3554.250000   \n",
       "max    112151.000000  73498.000000  92780.000000  60869.000000   \n",
       "\n",
       "       Detergents_Paper    Delicassen  \n",
       "count        440.000000    440.000000  \n",
       "mean        2881.493182   1524.870455  \n",
       "std         4767.854448   2820.105937  \n",
       "min            3.000000      3.000000  \n",
       "25%          256.750000    408.250000  \n",
       "50%          816.500000    965.500000  \n",
       "75%         3922.000000   1820.250000  \n",
       "max        40827.000000  47943.000000  "
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_data=t.drop(['Channel','Region'],axis=1)\n",
    "new_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据预处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import Normalizer\n",
    "np.set_printoptions(suppress=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.00011182, 0.00016773, 0.7083327 , ..., 0.01196489, 0.14950522,\n",
       "        0.07480852],\n",
       "       [0.00012532, 0.00018798, 0.44219825, ..., 0.11040858, 0.20634248,\n",
       "        0.11128583],\n",
       "       [0.00012484, 0.00018726, 0.39655168, ..., 0.15011912, 0.21946729,\n",
       "        0.4896193 ],\n",
       "       ...,\n",
       "       [0.00005016, 0.00007524, 0.36446153, ..., 0.01096068, 0.37223685,\n",
       "        0.04682745],\n",
       "       [0.00009113, 0.00027339, 0.93773739, ..., 0.09459392, 0.01531   ,\n",
       "        0.19365325],\n",
       "       [0.00024123, 0.00072368, 0.67229583, ..., 0.01567967, 0.11506463,\n",
       "        0.01254373]])"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nor=Normalizer(norm='l2')\n",
    "q=nor.transform(data)\n",
    "q"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.7083327 , 0.53987375, 0.42274082, 0.01196489, 0.14950522,\n",
       "        0.07480852],\n",
       "       [0.44219825, 0.61470382, 0.59953987, 0.11040858, 0.20634248,\n",
       "        0.11128583],\n",
       "       [0.39655168, 0.54979178, 0.47963216, 0.15011912, 0.21946729,\n",
       "        0.4896193 ],\n",
       "       ...,\n",
       "       [0.36446153, 0.38846468, 0.7585445 , 0.01096068, 0.37223685,\n",
       "        0.04682745],\n",
       "       [0.93773739, 0.1805304 , 0.20340426, 0.09459392, 0.01531   ,\n",
       "        0.19365325],\n",
       "       [0.67229583, 0.40960112, 0.60547633, 0.01567967, 0.11506463,\n",
       "        0.01254373]])"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b=np.delete(q,(0,1),axis=1)\n",
    "b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用轮廓系数找到最优K"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.cluster import KMeans \n",
    "from sklearn.metrics import silhouette_score #轮廓系数\n",
    "from sklearn.metrics import silhouette_samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.15834832,  0.45770606,  0.28318674,  0.20887783,  0.54755102,\n",
       "        0.1332028 ,  0.45532959,  0.30200539,  0.14841934,  0.63110632,\n",
       "        0.49173155,  0.60728694,  0.54841489,  0.31891502,  0.48800881,\n",
       "        0.6008978 ,  0.6243502 ,  0.06177291,  0.46969038,  0.11937781,\n",
       "        0.61423417,  0.03976191,  0.4933354 ,  0.19823472,  0.37440357,\n",
       "        0.51366827,  0.4853591 ,  0.63591353,  0.61755114,  0.60855267,\n",
       "        0.48301132,  0.21779187,  0.63049487,  0.60981548,  0.46112131,\n",
       "        0.607857  ,  0.63700946,  0.07266746,  0.60963723,  0.54491002,\n",
       "        0.33492758,  0.60551423,  0.38314804,  0.59561895,  0.26886745,\n",
       "        0.583854  ,  0.62423676,  0.43545669,  0.09855748,  0.63246911,\n",
       "        0.0622681 ,  0.53236193,  0.64012958,  0.59303287,  0.61995271,\n",
       "        0.15919662,  0.56933111,  0.55439595,  0.64527774,  0.40258778,\n",
       "       -0.0173171 ,  0.51627648,  0.08720882,  0.53795528,  0.24955627,\n",
       "        0.5848933 ,  0.51123631,  0.34533866,  0.04561477,  0.57986742,\n",
       "        0.06276208, -0.04607911,  0.44597625,  0.29133849,  0.27526099,\n",
       "        0.52648936,  0.10450124,  0.55621449,  0.61952937,  0.50023595,\n",
       "        0.57688178,  0.60285805,  0.28362277,  0.630481  ,  0.4822043 ,\n",
       "        0.62429548,  0.39764004,  0.50898439,  0.42916554,  0.63889888,\n",
       "        0.5145646 ,  0.16346993,  0.6147222 ,  0.42473055,  0.55364605,\n",
       "        0.5072704 ,  0.55571393,  0.38908694,  0.37853761, -0.02728655,\n",
       "        0.26091764,  0.62388606,  0.54073188,  0.48924759,  0.64391293,\n",
       "        0.63357984,  0.60456103,  0.53488693,  0.56011159,  0.52418335,\n",
       "        0.60382148,  0.43019354,  0.25503458,  0.58692424,  0.62518772,\n",
       "        0.56431902,  0.6183921 ,  0.22769549,  0.55142392,  0.21872489,\n",
       "        0.63828023,  0.05785475,  0.55650742,  0.06986976,  0.61453296,\n",
       "        0.56812246,  0.32939581,  0.52129439,  0.39307021,  0.59043762,\n",
       "        0.32308325,  0.57979527,  0.65063934,  0.65044712,  0.62177699,\n",
       "        0.55417365,  0.28670456,  0.51774318,  0.54256154,  0.08218029,\n",
       "        0.56409849,  0.53265277,  0.64127441,  0.25039418,  0.62243652,\n",
       "        0.32164683,  0.62371787,  0.55384981,  0.10463257,  0.60374718,\n",
       "        0.644252  ,  0.3249043 ,  0.62779125,  0.22328472,  0.64112786,\n",
       "        0.60830105,  0.57260358,  0.61297001,  0.63115367,  0.59548149,\n",
       "        0.54998281,  0.55727521,  0.62795782,  0.62384556,  0.4948018 ,\n",
       "        0.36473944,  0.53500026,  0.3853291 ,  0.5846349 ,  0.25650737,\n",
       "        0.60244535,  0.52526438,  0.624187  ,  0.57577766,  0.23184643,\n",
       "        0.63720786,  0.63040261,  0.40460726,  0.37887304,  0.25145181,\n",
       "        0.26556823,  0.61237401,  0.59252074,  0.18098652,  0.4565548 ,\n",
       "        0.23493559,  0.4141426 ,  0.34500561,  0.4576175 ,  0.58274327,\n",
       "        0.26037865,  0.61221936,  0.57889764,  0.48959387,  0.56585592,\n",
       "        0.21866893,  0.03482593,  0.63519697,  0.36333985,  0.64150806,\n",
       "        0.60680908,  0.60723208,  0.41179958,  0.51115011,  0.26335029,\n",
       "        0.60822925,  0.64908666,  0.42466299,  0.55013663,  0.58991578,\n",
       "        0.62139803,  0.62859649,  0.55289413,  0.56828389,  0.62744101,\n",
       "        0.63262539,  0.60453208,  0.633347  ,  0.52245589,  0.07998605,\n",
       "        0.62693238,  0.56411612,  0.49043667,  0.25031752,  0.64814953,\n",
       "        0.61851476,  0.55658435,  0.02903121,  0.04337653,  0.31444086,\n",
       "        0.26293686,  0.32892086,  0.63873069,  0.42578829,  0.53011498,\n",
       "        0.34925117,  0.51385315,  0.51784654,  0.61122278,  0.62243409,\n",
       "        0.13740051,  0.6375342 ,  0.59149996,  0.51721907,  0.52688091,\n",
       "        0.57607178,  0.5879443 ,  0.57489516,  0.58778689,  0.27451455,\n",
       "        0.01960602,  0.60268903,  0.4458525 ,  0.49708975,  0.07999879,\n",
       "        0.58856539,  0.48713231, -0.01121218,  0.60556557,  0.64660131,\n",
       "        0.48221544,  0.2982893 ,  0.6197603 ,  0.13118084,  0.62591006,\n",
       "        0.24837568,  0.56325431,  0.57118722,  0.4246331 ,  0.58181597,\n",
       "        0.4290396 ,  0.16877733,  0.47553204,  0.6026703 ,  0.39273518,\n",
       "        0.09572377,  0.63529048,  0.41483526,  0.18022879,  0.46569157,\n",
       "        0.07018768,  0.36563418,  0.62881587,  0.36881864,  0.64030638,\n",
       "        0.60224396,  0.51069505,  0.10474991,  0.61480664,  0.56571795,\n",
       "        0.1817202 ,  0.15437274,  0.09448998,  0.61811106,  0.62779077,\n",
       "        0.34940776,  0.63307686, -0.06267767,  0.41294867,  0.54036337,\n",
       "        0.53696372,  0.63035398,  0.59869133,  0.5015597 ,  0.5509176 ,\n",
       "        0.50211217,  0.62715457,  0.65896259,  0.5804885 ,  0.50031685,\n",
       "        0.47998145,  0.62431742,  0.43817481,  0.2850722 ,  0.38939046,\n",
       "        0.53312779,  0.3874532 ,  0.52550669,  0.59480858,  0.51147292,\n",
       "        0.36738209,  0.37389065,  0.56300352,  0.29551313,  0.63922762,\n",
       "        0.4996294 ,  0.31885111,  0.43605802,  0.26835462,  0.35339026,\n",
       "        0.32358638,  0.58803112,  0.61483611,  0.45454629,  0.11738563,\n",
       "        0.57996169,  0.63886662,  0.34548696,  0.30820661,  0.4054336 ,\n",
       "        0.53569767,  0.61825668,  0.5609812 ,  0.52325053,  0.24618643,\n",
       "        0.56711562,  0.58834006,  0.54138718,  0.11552249,  0.61513462,\n",
       "       -0.06538156,  0.58243566,  0.28020458,  0.5525504 ,  0.15356934,\n",
       "        0.50551535,  0.55438599,  0.44267996,  0.1036026 ,  0.33463555,\n",
       "        0.63384142,  0.57721712,  0.18464944,  0.12245999,  0.18133263,\n",
       "        0.50944844,  0.63573768,  0.32360768,  0.63070051,  0.60866559,\n",
       "        0.6449585 ,  0.3639783 ,  0.06380706,  0.46791929,  0.51166692,\n",
       "        0.62745443,  0.48797374,  0.61904364,  0.06293802,  0.49704734,\n",
       "        0.60055171,  0.07170168,  0.64715118,  0.31294212,  0.36814053,\n",
       "        0.59018712,  0.26819399,  0.6306915 ,  0.62425859,  0.49727103,\n",
       "        0.500792  ,  0.0954084 ,  0.47346338,  0.40348151,  0.63249964,\n",
       "        0.50901643,  0.489176  , -0.03392153,  0.25042345,  0.61087054,\n",
       "        0.30715537,  0.2248182 ,  0.63863612,  0.53646732,  0.56489547,\n",
       "        0.52204121,  0.39310446,  0.60397194,  0.15977331,  0.18183881,\n",
       "        0.31105088,  0.13849105,  0.53269065,  0.45980146,  0.38837217,\n",
       "        0.28660111,  0.59133005,  0.55226599,  0.60044985,  0.51179075,\n",
       "        0.57014844,  0.50080002,  0.63810776,  0.63720411,  0.38266459,\n",
       "        0.4639379 ,  0.24619199,  0.12093285,  0.36297809,  0.52407327,\n",
       "        0.45513151,  0.50225668,  0.62816781,  0.01630072,  0.54901273,\n",
       "        0.16757597,  0.58120843,  0.55170893,  0.60605809, -0.01770549])"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cluster = KMeans(n_clusters=3, random_state=0).fit(b)\n",
    "silhouette_score(b,cluster.labels_) #计算所有样本的轮廓系数均值。\n",
    "silhouette_samples(b,cluster.labels_) #计算每个样本的轮廓系数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.lines.Line2D at 0x1a5abbb1160>"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAqG0lEQVR4nO3deXxU9bnH8c8zWYCEnQABggQFKUkQhYB4pdaqSLoorSsuCC5grdjWLtZ6b+0t9nqv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F5ncB7gFOAXD3XxHuy/N5YB2wH7gxQfK6ArjNzCqBA8D4oAsE4dVAsyz8lZAh4Dl3f8mObUr3KPCkma0DdhEuJEGLJq+vWfirKSsjeU1qgrzqlADHK5q84nW8egIvROplMvC0u883s69AXD+T0eQVj88kwB3Ab80sFdgA3Bjk8VILBBGRFq7ZTd2IiMjJUaEXEWnhVOhFRFo4FXoRkRZOhV5EpIVToRcRaeFU6EVEWrj/B23Jn6BRLE9TAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "score=[]\n",
    "for i in range(2,7):\n",
    "    cluster= KMeans(n_clusters=i, random_state=0).fit(b)\n",
    "    score.append(silhouette_score(b,cluster.labels_))\n",
    "plt.plot(range(2,7),score)\n",
    "plt.axvline(pd.DataFrame(score).idxmin()[0]+2,ls=':')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 建模与可视化分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [],
   "source": [
    "#通过学习曲线,选择k=3 的时候为最优\n",
    "# 重新建模\n",
    "kmeans = KMeans(n_clusters=3,random_state=665)\n",
    "#训练模型,并将聚类结果保存到变量中\n",
    "y_pred = kmeans.fit_predict(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 2,\n",
       "       0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 2, 1,\n",
       "       1, 0, 2, 0, 2, 1, 2, 0, 1, 0, 2, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0,\n",
       "       2, 0, 0, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1,\n",
       "       0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 1, 0, 2, 0,\n",
       "       0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 2, 0, 0, 1, 0, 1,\n",
       "       0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1,\n",
       "       0, 0, 0, 2, 0, 0, 1, 2, 1, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 0, 2, 1,\n",
       "       0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 2,\n",
       "       0, 1, 2, 2, 0, 0, 0, 2, 1, 2, 2, 1, 0, 1, 0, 1, 0, 0, 0, 0, 2, 0,\n",
       "       0, 0, 1, 1, 0, 0, 0, 2, 2, 1, 2, 0, 1, 0, 0, 2, 0, 0, 0, 2, 0, 1,\n",
       "       1, 1, 1, 0, 1, 0, 2, 1, 1, 0, 1, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0,\n",
       "       0, 2, 0, 0, 1, 2, 2, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0,\n",
       "       0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 2, 1, 0, 2,\n",
       "       0, 1, 0, 1, 2, 0, 0, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 0, 2, 1, 2, 1,\n",
       "       1, 1, 2, 1, 0, 1, 1, 1, 0, 0, 1, 0, 2, 1, 0, 0, 0, 0, 0, 0, 2, 0,\n",
       "       0, 0, 1, 0, 1, 1, 0, 2, 0, 2, 1, 0, 1, 0, 0, 0, 2, 1, 1, 0, 0, 0,\n",
       "       1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1,\n",
       "       1, 0, 1, 0, 0, 0, 0, 2, 1, 2, 1, 0, 1, 2, 0, 2, 0, 2, 0, 1, 0, 1])"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p=y_pred\n",
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.915256</td>\n",
       "      <td>0.163631</td>\n",
       "      <td>0.223793</td>\n",
       "      <td>0.138953</td>\n",
       "      <td>0.048818</td>\n",
       "      <td>0.067956</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.261594</td>\n",
       "      <td>0.487486</td>\n",
       "      <td>0.679854</td>\n",
       "      <td>0.094596</td>\n",
       "      <td>0.267225</td>\n",
       "      <td>0.099340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.606039</td>\n",
       "      <td>0.252778</td>\n",
       "      <td>0.278282</td>\n",
       "      <td>0.576022</td>\n",
       "      <td>0.054585</td>\n",
       "      <td>0.115706</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Fresh      Milk   Grocery    Frozen  Detergents_Paper  Delicassen\n",
       "0  0.915256  0.163631  0.223793  0.138953          0.048818    0.067956\n",
       "1  0.261594  0.487486  0.679854  0.094596          0.267225    0.099340\n",
       "2  0.606039  0.252778  0.278282  0.576022          0.054585    0.115706"
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt=kmeans.cluster_centers_\n",
    "dt_data=pd.DataFrame(data=dt,index=None,columns=['Fresh','Milk','Grocery','Frozen','Detergents_Paper','Delicassen'])\n",
    "dt_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      0\n",
       "1      1\n",
       "2      1\n",
       "3      0\n",
       "4      0\n",
       "      ..\n",
       "435    2\n",
       "436    0\n",
       "437    1\n",
       "438    0\n",
       "439    1\n",
       "Length: 440, dtype: int32"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l_data=pd.Series(p)\n",
    "l_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [],
   "source": [
    "tudata=l_data.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.patches.Wedge at 0x1a5b14660f0>,\n",
       "  <matplotlib.patches.Wedge at 0x1a5b1466b38>,\n",
       "  <matplotlib.patches.Wedge at 0x1a5b146e390>],\n",
       " [Text(0.1643163533144698, 1.0876580970293166, '0'),\n",
       "  Text(-0.6337903412365016, -0.8990605115092749, '1'),\n",
       "  Text(0.983647761223074, -0.4923790022338833, '2')],\n",
       " [Text(0.08962710180789261, 0.5932680529250818, '45.23%'),\n",
       "  Text(-0.34570382249263715, -0.49039664264142263, '40.00%'),\n",
       "  Text(0.536535142485313, -0.2685703648548454, '14.77%')])"
      ]
     },
     "execution_count": 158,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOcAAADnCAYAAADl9EEgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAd9klEQVR4nO3deXhU9b3H8feZJQtJGCDsYRkWRUDwihuICwouOC6tVWsfa1Otti69rWirU9vq2NqaLreurbUWrrugqBUdl+u+L+A67OsICVnINklIMpk559w/TlgCAZKQmd+Zme/refIQ40x+n/Dkw9l/P800TYQQ9uNQHUAI0TkppxA2JeUUwqaknELYlJRTCJuScgphU1JOIWxKyimETUk5hbApKacQNiXlFMKmpJxC2JSUUwibknIKYVNSTiFsSsopOtA07UxN09ZomrZe0zS/6jyZTJOHrcUOmqY5gbXAaUApsBT4nmmaK5UGy1Cy5RS7OxZYb5rmRtM024CFwHmKM2UsKafYXRGwZbf/Lm3/mlBAyimETUk5xe7KgJG7/feI9q8JBaScYndLgUM0TRujaVoWcDGwRHGmjOVSHUDYh2macU3Tfgq8CjiBBaZprlAcK2PJpRQhbEp2a4WwKSmnEDYl5RTCpuSEkI15/UENGAqM2uNjBJAPZO/2kbPb5w6gAagHIp38WQ5sBDYAZeESn5Gcn0h0h5wQsgmvPzgQOGa3j0lYJcxK8NBRYB2wAlgJLAc+Cpf4yhM8rjgAKacCXn/QBRwHzGBXGccoDbW39cA7wLvAO+ES3zeK82QcKWeSeP1BDzAXOKf9z/5qE3XbZqyyvgY8Hy7xNSjOk/aknAnk9QfHYpXxXOBEwK02Ua+JAq8Ai4Al4RLfdsV50pKUs5d5/cFc4CLgJ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XYK3VOFB1lAy1HLiyfYb/jCdbzt0FIouByVjLwsm/WsnTivW43zQp5i5pv+XUNG0BcDZQZZrm4V1+Y8AzHbgPOCpB0YTlDeAqApH1qoPYTSaU8ySs5esf6VY5YccZ3Suw1ggt7P10Ge0b4DcEIo+pDmJXaV9O2LkS8YvdLucOAU9/rFncfgyk3rrw9lIF3A48QCAiE4Pvh5SzOwKeIuAmrCUhcg4+WUaJAH8B7iIQ2a46TCqQcvZEwDMUa8b5q4A+vfI901cd1tQxfyEQqVUdJpVIOQ9GwDMIuB7ruFQuv3S0ArgXeJRApFl1mFQk5ewNAU8W8G2sY9JT2LV6fKYxsO5ZvptA5A3VYVJd2pdT07QngVlYW7ZK4FbTNOcnbMCAZzzWlvSHwJCEjWMvq4CFwGMEIim3YJBdpX05lQl43MBs4DzgXGC42kC9bj3WWiSLCESSuf5JxpByJkPAowFHA9/CKutkpXl6Jo61/sibwHMEIp8pzpP2pJwqBDxe4ESs50qPBw7Hfo+tGcAXWCtCvwm8RyDS0+krRQ9IOe0g4CnAmqHheGAacAgwjuRdS23Cuul8ORBq//Pz9lXchCJSTruydoVHYhV1x8dQoD/Qr/3PHZ/v666lONZN5duAik4+yrAueXxDICK/CDYj5UwHAU8O4NrtKzoQbZ9cW6QoKacQNiXPcwphU1JOIWxKyimETUk5hbApKacQNiXlFMKmpJxC2JSUUwibknIKYVNSTiFsSsophE1JOYWwKSmnEDYl5RTCpqScQtiUlFMIm5JyCmFTUk4hbErKKYRNSTmFsCkppxA2JeUUwqaknELYlJRTCJuScgphU1JOIWxKyimETf0/dPhCunUPH3sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.pie(x=tudata.values,labels=tudata.index,autopct=\"%.2f%%\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.9152559337283869,\n",
       " 0.16363071149629815,\n",
       " 0.22379331283577905,\n",
       " 0.1389531841271251,\n",
       " 0.04881770597413872,\n",
       " 0.06795594277756185,\n",
       " 0.26159394157936366,\n",
       " 0.4874862385561649,\n",
       " 0.6798535882905856,\n",
       " 0.0945956070924127,\n",
       " 0.2672245438511889,\n",
       " 0.09934026737553324,\n",
       " 0.6060392576243245,\n",
       " 0.252777549837924,\n",
       " 0.2782821500954683,\n",
       " 0.5760223472070399,\n",
       " 0.05458481518256325,\n",
       " 0.11570644183780018]"
      ]
     },
     "execution_count": 227,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dt_list=[]\n",
    "for i in dt:\n",
    "    for j in i:\n",
    "        dt_list.append(j)\n",
    "dt_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 235,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.915256</td>\n",
       "      <td>Fresh</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.163631</td>\n",
       "      <td>Milk</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.223793</td>\n",
       "      <td>Grocery</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.138953</td>\n",
       "      <td>Frozen</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.048818</td>\n",
       "      <td>Detergents_Paper</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.067956</td>\n",
       "      <td>Delicassen</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.261594</td>\n",
       "      <td>Fresh</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.487486</td>\n",
       "      <td>Milk</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.679854</td>\n",
       "      <td>Grocery</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.094596</td>\n",
       "      <td>Frozen</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.267225</td>\n",
       "      <td>Detergents_Paper</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.099340</td>\n",
       "      <td>Delicassen</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.606039</td>\n",
       "      <td>Fresh</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.252778</td>\n",
       "      <td>Milk</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.278282</td>\n",
       "      <td>Grocery</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.576022</td>\n",
       "      <td>Frozen</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.054585</td>\n",
       "      <td>Detergents_Paper</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.115706</td>\n",
       "      <td>Delicassen</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           a                 b  c\n",
       "0   0.915256             Fresh  1\n",
       "1   0.163631              Milk  1\n",
       "2   0.223793           Grocery  1\n",
       "3   0.138953            Frozen  1\n",
       "4   0.048818  Detergents_Paper  1\n",
       "5   0.067956        Delicassen  1\n",
       "6   0.261594             Fresh  2\n",
       "7   0.487486              Milk  2\n",
       "8   0.679854           Grocery  2\n",
       "9   0.094596            Frozen  2\n",
       "10  0.267225  Detergents_Paper  2\n",
       "11  0.099340        Delicassen  2\n",
       "12  0.606039             Fresh  3\n",
       "13  0.252778              Milk  3\n",
       "14  0.278282           Grocery  3\n",
       "15  0.576022            Frozen  3\n",
       "16  0.054585  Detergents_Paper  3\n",
       "17  0.115706        Delicassen  3"
      ]
     },
     "execution_count": 235,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_data=pd.DataFrame(data=dt_list)\n",
    "n_data['p']=['Fresh','Milk','Grocery','Frozen','Detergents_Paper','Delicassen','Fresh','Milk','Grocery','Frozen','Detergents_Paper','Delicassen','Fresh','Milk','Grocery','Frozen','Detergents_Paper','Delicassen']\n",
    "n_data['a']=[1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3]\n",
    "n_data.columns=['a','b','c']\n",
    "n_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 236,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAe1ElEQVR4nO3deXAVVf738feXAAZBGZY4IkGC87BnuZAQ0Agq/ABFJgiiI6u4jLLqiDJiwYAGfMaF0Solo4OlIuMWBwVRmQERUKFQCBiQPYBR4vjIIoIBogTO80dCfiEmEEg6N7n9eVVRdbvv6b7f5lbdT87p7tPmnENERPyrRrALEBGR4FIQiIj4nIJARMTnFAQiIj6nIBAR8bmawS7gbDVu3NhFRUUFuwwRkWpl7dq1+5xzESW9V+2CICoqivT09GCXISJSrZjZ16W9p6EhERGfUxCIiPicgkBExOeq3TmCkhw7dozs7Gxyc3ODXYpUgvDwcCIjI6lVq1awSxEJCSERBNnZ2VxwwQVERUVhZsEuRzzknGP//v1kZ2fTokWLYJcjEhJCYmgoNzeXRo0aKQR8wMxo1KiRen8iFSgkggBQCPiIvmuRihUyQSAiIudGQVANZWVlER0dHewyRCREhMTJ4tJs3r3vnLdt16xxBVYiIlJ1qUdQTeXl5TFkyBDatm3LwIEDOXLkSLBLEpFqSkFQTW3bto3Ro0ezZcsWLrzwQv7+978HuyQRqaYUBNVUs2bNSEpKAmDo0KGsWLEiyBWJSHWlIKimil9CqUsqReRcKQiqqW+++YZVq1YB8Prrr3PllVcGuSIRqa4UBNVU69atSU1NpW3bthw4cIBRo0YFuyQRqaZC+vLRUBUVFcXWrVuDXYaIhAj1CEREfE5BICLicwoCERGfUxCIiPicgkBExOcUBCIiPheSl4/GT5hToftb++TwM7YJCwsjJiamcHn+/PlERUWd82dGRUWRnp5O48aaBVVEvBWSQRAMderUISMjo8T3nHM456hRQx0wEal69MvkkaysLFq3bs3w4cOJjo5m9+7dPPnkk3Tq1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VG0Kgmqq+Ilmr3z55ZcMGzbslHXnnXcen3/++VntZ/bs2RVYlYhUJAWBnFZMTMyvrgwSkdCiO4tFRHxOQSAi4nMKAhERnwvJcwSPDi3/JYrzirye9OrcM7YPCwsjJiam8D6C4cOHc99991GjRulZm5WVRd++fdm4cSPp6enMmTOHZ555pty1i4icjZAMgmA4l2moi0pISCAhocRLfEVEPKWhIQ+UdRrqopYvX07fvn2B/JvFbrvtNmJiYoiNjeXtt98GYNSoUSQkJNC+fXumTp1auO3EiRNp164dsbGxPPDAA0D+dA7R0dHExcXRrVs34PRTPl999dUMHDiQNm3aMGTIEKrbjYYicu7UI/BIWaahLj4J20nTpk2jfv36fPnllwAcOHAAgEcffZSGDRty/PhxevTowYYNG2jatCnz5s1j69atmBk//vgjACkpKSxatIimTZsWrnvxxRdLnfL5iy++YNOmTVxyySUkJSWxcuVKrrzySm//k0SkSlCPoBIsXryYOXPmEAgE6Ny5M/v37yczM7PU9kuWLGHMmDGFyw0aNADgrbfeomPHjnTo0IFNmzaxefNm6tevT3h4OHfccQfvvPMO559/PpA/Md2IESN44YUXOH78+BnrSExMJDIykho1ahAIBEqdplpEQo96BB4pyzTUZ/Nj+9VXXzFjxgzWrFlDgwYNGDFiBLm5udSsWZPVq1fz0UcfMXfuXGbOnMnSpUt5/vnn+fzzz/nggw+Ij49n7dq1p53y+eQU1XD6aapFJPSoR+CB0qahPnbsGADbt2/n8OHDpW7fs2dPUlNTC5cPHDjAoUOHqFu3LvXr1+f777/n3//+N5B/PuHgwYP06dOHp59+mvXr1wP500l37tyZlJQUIiIi2L1791nXISL+UOYegZk1AFoChc8udM594kVR5XXycs/KnH30XKahLs3kyZMZM2YM0dHRhIWFMXXqVAYMGECHDh1o06YNzZo1Iykpf4bMn376iX79+pGbm4tzjqeeegqACRMmkJmZiXOOHj16EBcXR2xsrG+mfP4mJebcN25wYcUVIlINlGkaajO7E7gXiAQygC7AKudcd0+rK4GmoRY48zTU5QmCQecYBJqG+n9pGuqq53TT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Hhd74YAgtR+u6qN99+f56dLBYRkepBdxaLiPicgkBExOcUBFWEmb1kZnsK7q2QasTMmpnZMjPbbGabzOzeYNckZWdm4Wa22szWF3x/jwS7psqmcwRVhJl1A3KAOc656GDXI2VnZk2AJs65dWZ2AbAWuME5tznIpUkZFMxmUNc5l2NmtYAVwL3Ouc+CXFqlUY+ginDOfUL+lVNSzTjnvnPOrSt4/ROwBWga3KqkrFy+nILFWgX/fPUXsoJApAIVzKDbAfg8yKXIWTCzMDPLAPYAHzrnfPX9KQhEKoiZ1QPeBv7knDsU7Hqk7Jxzx51zAfJnQEg0M18NzyoIRCpAwdjy28Brzrl3gl2PnBvn3I/AMuDaIJdSqRQEIuVUcLLxRWCLc+6pYNcjZ8fMIszsNwWv6wA9ga1BLaqSKQiqCDN7A1gFtDazbDO7I9g1SZklAcOA7maWUfCvT7CLkjJrAiwzsw3kz5H2oXPu/SDXVKl0+aiIiM+pRyAi4nMKAhERn1MQiIj4nIJARMTnFAQiIj6nIBAR8TkFgYiIzykIRCqAmQ03sw0Fc9r/M9j1iJwN3VAmUk5m1h6YB1zhnNtnZg2dc5pSXKoN9QhEyq878C/n3D4AhYBUNwoCERGfUxCIlN9S4CYzawRgZg2DXI/IWdE5ApEKYGa3AhOA48AXzrkRwa1IpOwUBCIiPqehIRERn1MQiIj4nIJARMTnFAQiIj6nIBAR8TkFgYiIzykIRER87v8Du/13452zbjEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#使用seaborn方法画图\n",
    "ax = sns.barplot(x=\"c\", y=\"a\", hue='b',data=n_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
